[FLINK-40225][table] Reject trailing tokens in JSON functions - #28815
Open
VasShabu wants to merge 4 commits into
Open
[FLINK-40225][table] Reject trailing tokens in JSON functions#28815VasShabu wants to merge 4 commits into
VasShabu wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Thanks for the PR, @VasShabu. The fix sounds reasonable, added two small suggestions.
Also, some nits:
- PR/commit title says "Leading token" but the fix is FAIL_ON_TRAILING_TOKENS - trailing invalid tokens. Rename it to something short but informative like: "[FLINK-40225][table] Reject trailing tokens in JSON functions"
- Make sure to rebase your changes on top of master
- Make sure the CI is green
| .testResult( | ||
| $("f0").isJson(JsonType.OBJECT), | ||
| "f0 IS JSON OBJECT", | ||
| true, | ||
| BOOLEAN())); | ||
| BOOLEAN().notNull()), | ||
| TestSetSpec.forFunction(BuiltInFunctionDefinitions.IS_JSON) |
Contributor
There was a problem hiding this comment.
Since the same mapper now affects every JSON function, could we add a trailing-garbage case for JSON_VALUE/JSON_QUERY/JSON_EXISTS as well (e.g. {"a":1} x)? Right now a future revert of the flag would only fail the IS JSON specs
| .testResult( | ||
| $("f0").isJson(JsonType.OBJECT), | ||
| "f0 IS JSON OBJECT", | ||
| true, | ||
| BOOLEAN())); | ||
| BOOLEAN().notNull()), | ||
| TestSetSpec.forFunction(BuiltInFunctionDefinitions.IS_JSON) |
Contributor
There was a problem hiding this comment.
You have multiple TestSetSpec, but you could group them under one single TestSetSpec as the tests above do
Suggested change
| TestSetSpec.forFunction(BuiltInFunctionDefinitions.IS_JSON) | |
| TestSetSpec.forFunction(BuiltInFunctionDefinitions.IS_JSON) | |
| .onFieldsWithData("{} dsfsd", "true randomGarbage", "null, randomGarbage") |
VasShabu
force-pushed
the
jsonLeadingTokenBug
branch
from
July 29, 2026 14:49
9045511 to
85eea99
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fixed the bug which causes some invalid JSON elements being parsed correctly without issue.
Brief change log
(for example:)
Verifying this change
Please make sure both new and modified tests in this PR follow the conventions for tests defined in our code quality guide.
This change added tests and can be verified as follows:
Some tests were added as this PR
./mvnw -o -pl flink-table/flink-table-planner -Dtest='JsonFunctionsITCase' -Dsurefire.failIfNoSpecifiedTests=false -Dcheckstyle.skip=true -Dspotless.check.skip=true -e -Drat.skip=true -Denforcer.skip=true testPreviously these functions returned true
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (no)Documentation